package com.webapp.domain.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.webapp.domain.util.Global;

import com.alibaba.fastjson.annotation.JSONField;

/**
 * 纠纷表
 * @author zern
 *
 */
@Entity
@Table(name = "disputes")
public class Disputes extends BaseEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5316171944435975114L;
	
	private Long id;	// id
	
	private String caseNo;		// 案件编号

	private String type;		// 案件类型
	
	private String caseNumber;   //评估案号
	private String evaluateNo;   
	private String status;		// 状态，进展
	
	private Date createTime;	// 创建时间
		
	private User user;			// 创建用户
	
	private Proposer proposer;	// 申请人信息
	private Arbdic arbdic;   //在线仲裁接口记录disp状态
	private Evaluate evaluate;//在线评估表
	
	private DisputesData disputesData;	// 详细信息
	
	private String delFlag = Global.NOTDELETE;	// 0是正常，1 是已删除
	
	private List<Session> sessions;
	
	private Long messageCount;	// 未读消息
	
	private String visible;//1公开 、 0隐藏
	
	private Long mediatorId;//调解员id
	private String mediatorCode;
	private Mediation mediation;//网上调解状态
	
	
	@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@JoinColumn(name = "mediation_id", referencedColumnName = "id")
	@JSONField(serialize = false)
	public Mediation getMediation() {
		return mediation;
	}

	public void setMediation(Mediation mediation) {
		this.mediation = mediation;
	}

	public String getMediatorCode() {
		return mediatorCode;
	}

	public void setMediatorCode(String mediatorCode) {
		this.mediatorCode = mediatorCode;
	}

	

	public Long getMediatorId() {
		return mediatorId;
	}

	public void setMediatorId(Long mediatorId) {
		this.mediatorId = mediatorId;
	}

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name = "id")
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	
	@Column(name = "status", length = 2)
	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}
	
	@Column(name = "type", length = 2)
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}
	@Column(name = "create_time",updatable = false)
	@JSONField(format = "yyyy/MM/dd")
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "user_id", referencedColumnName = "id")
	@JSONField(serialize = false)
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@OneToOne(mappedBy = "disputes", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
	public DisputesData getDisputesData() {
		return disputesData;
	}
	
	public void setDisputesData(DisputesData disputesData) {
		this.disputesData = disputesData;
	}

	@OneToOne(mappedBy = "disputes", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
	public Proposer getProposer() {
		return proposer;
	}


	public void setProposer(Proposer proposer) {
		this.proposer = proposer;
	}
	@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@JoinColumn(name = "arbdic_id", referencedColumnName = "id")
	@JSONField(serialize = false)
	public Arbdic getArbdic() {
		return arbdic;
	}

	public void setArbdic(Arbdic arbdic) {
		this.arbdic = arbdic;
	}
	@Column(name = "case_no", length =20)
	public String getCaseNo() {
		return caseNo;
	}

	public void setCaseNo(String caseNo) {
		this.caseNo = caseNo;
	}
	@Column(name= "case_number", length=15)
	public String getCaseNumber() {
		return caseNumber;
	}
	public void setCaseNumber(String caseNumber) {
		this.caseNumber = caseNumber;
	}

	@Column(name = "del_flag", length = 2, updatable = false)
	@JSONField(serialize = false)
	public String getDelFlag() {
		return delFlag;
	}

	public void setDelFlag(String delFlag) {
		this.delFlag = delFlag;
	}

	@OneToMany(mappedBy="disputes",cascade=CascadeType.ALL,fetch=FetchType.LAZY)
	@JSONField(serialize = false)
	public List<Session> getSessions() {
		return sessions;
	}

	public void setSessions(List<Session> sessions) {
		this.sessions = sessions;
	}

	@Transient
	public Long getMessageCount() {
		return messageCount;
	}

	public void setMessageCount(Long messageCount) {
		this.messageCount = messageCount;
	}

	public String getVisible() {
		return visible;
	}

	public void setVisible(String visible) {
		this.visible = visible;
	}

	public String getEvaluateNo() {
		return evaluateNo;
	}

	public void setEvaluateNo(String evaluateNo) {
		this.evaluateNo = evaluateNo;
	}
	@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@JoinColumn(name = "evaluate_id", referencedColumnName = "id")
	@JSONField(serialize = false)
	public Evaluate getEvaluate() {
		return evaluate;
	}

	public void setEvaluate(Evaluate evaluate) {
		this.evaluate = evaluate;
	}

	
}
